package com.kk.springboot_002.mapper;

import com.kk.springboot_002.pojo.User;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PathVariable;

@Mapper
public interface UserMapper {
    @Select("select * from user where name = #{userName}")
    User findByUserName(@PathVariable("userName") String userName);

    @Insert("insert into user(name, password, email) values(#{name}, #{password}, #{email})")
    void save(User user);

    @Update("update user set name = #{name}, password = #{password}, email = #{email} where name = #{name}")
    void update(User user);

    @Delete("delete from user where name = #{username}")
    void deleteByUsername(String username);

    @Delete("delete from fruit where user_id = #{id}")
    void deleteFruitsByUserId(Integer id);
}
